package com.chrray.position.controller.web.sysUser;




import com.chrray.position.entity.position.SysRole;
import com.chrray.position.pojo.dto.auth.SysMenuTreeDto;

import com.chrray.position.pojo.dto.util.BaseAllDto;
import com.chrray.position.service.auth.SysJurisdictionService;
import com.chrray.position.util.result.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * Created by IntelliJ IDEA.
 *
 * @Author: Q
 * @Created: 2021/1/12 19:54
 * @Description:
 * @Versions: 1.0
 */

@RestController

@RequestMapping("api/web/common/auth")
@Api(value  = "系统角色/菜单", tags  = "系统权限及相关")
@Slf4j
@ResponseBody
public class AuthController {

    @Resource
    private SysJurisdictionService sysJurisdictionService;

    @GetMapping("/roleAll")
    @ApiOperation(value = "全部角色（不分页）")
    public ResponseResult<SysRole> roleAll(BaseAllDto dto) {
        return sysJurisdictionService.roleAll(dto);
    }

    @GetMapping("/roleAllON")
    @ApiOperation(value =  "已启用角色（不分页）")
    public ResponseResult<SysRole> roleAllNotDefault(BaseAllDto dto) {
        return sysJurisdictionService.roleAllNotDefault( dto);
    }

    @GetMapping("/menuAll")
    @ApiOperation(value =  "查询所有菜单和按钮权限")
    public ResponseResult<List<SysMenuTreeDto>> menuAll() {

        return sysJurisdictionService.menuAll();
    }


    @GetMapping("/myMenuOperation")
    @ApiOperation(value =  "查询用户拥有的菜单和按钮权限")
    public ResponseResult<List<SysMenuTreeDto>> myMenuOperation(BaseAllDto baseSysDto) {
        return sysJurisdictionService.myMenuOperation(baseSysDto);
    }


    @GetMapping("/myMenu")
    @ApiOperation(value =  "查询用户拥有的菜单权限")
    public ResponseResult<List<SysMenuTreeDto>> myMenu(BaseAllDto baseSysDto) {
        return sysJurisdictionService.myMenu(baseSysDto);
    }


    @GetMapping("/myMenuAndBtn")
    @ApiOperation(value =  "查询用户拥有的菜单和按钮权限(无层级)")
    public ResponseResult<List<SysMenuTreeDto>> myMenuAndBtn(BaseAllDto baseSysDto) {
        return sysJurisdictionService.myMenuAndBtn(baseSysDto);
    }
}

